import os
import sys

def copytree(src, dst, symlinks=0):
    names = os.listdir(src)
    #if destination is a directory and does not exist	
    if not os.path.exists(dst):
    	os.mkdir(dst)

    for name in names:
	print "file/dir name " + name
        srcname = os.path.join(src, name)
        dstname = os.path.join(dst, name)
        try:
            if symlinks and os.path.islink(srcname):
                linkto = os.readlink(srcname)
                os.symlink(linkto, dstname)
            elif os.path.isdir(srcname):
                copytree(srcname, dstname, symlinks)
            elif not os.path.exists(dstname):
                #copy2(srcname, dstname)
		os.symlink(srcname, dstname)
        except (IOError, os.error), why:
            print "Can't copy %s to %s: %s" % (`srcname`, `dstname`, str(why))

if __name__ == "__main__":
	copytree(sys.argv[1], sys.argv[2])
#        for patient in sys.argv[1:]:
#                plotL(patient,"./")
#        #plotL(sys.argv[1],"./")


